﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Reviewer.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix"), DataContract(Namespace = "Reviewer.Entities")]
    public sealed class MembersAttribute : IExtensibleDataObject
    {
        public static bool operator ==(MembersAttribute item1, MembersAttribute item2)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(item1, item2))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)item1 == null) || ((object)item2 == null))
            {
                return false;
            }

            return item1.Equals(item2);
        }
        public static bool operator !=(MembersAttribute item1, MembersAttribute item2)
        {
            return !(item1 == item2);
        }

        [DataMember(IsRequired = true)]
        public Guid MembersId { get; set; }
        [DataMember(IsRequired = true)]
        public String Key { get; set; }
        [DataMember(IsRequired = true)]
        public String Value { get; set; }

        public override bool Equals(object obj)
        {
            MembersAttribute second = obj as MembersAttribute;
            if (second != null)
            {
                return this.MembersId.Equals(second.MembersId)
                    && this.Key.Equals(second.Key)
                    && this.Value.Equals(second.Value);
            }
            return false;
        }

        public override int GetHashCode()
        {
            return (this.MembersId.GetHashCode() + this.Key.GetHashCode()).GetHashCode();
        }

        #region IExtensibleDataObject Members
        ExtensionDataObject IExtensibleDataObject.ExtensionData { get; set; }
        #endregion
    }
}
